<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function imageAsync(url){
            return new Promise((resolve,reject) =>{
                let image = new Image()
                img.onload = () =>{
                    console.log('图片请求成功')
                    resolve(image)
                }
                img.onerror = (err) =>{
                    console.log('失败');
                    reject(err)
                    
                }
            })
        }
        imageAsync("url").then(()=>{
            console.log("成功");
            
        }).catch((err) =>{
            console.log("失败");
            
        })
    </script>
</body>
</html>